//
//  Order.swift
//  ShopIOS
//
//  Created by Apple on 2019/7/26.
//  Copyright © 2019 Apple. All rights reserved.
//

import Foundation
import SwiftyJSON

struct mOrder {
    var WaitingForRecieve: Int = 0
    var Success: String?
    var AllOrderCounts: Int = 0
    var Orders = [mOrders]()
    var WaitingForComments: Int = 0
    var WaitingForPay: Int = 0
    
    init(json: JSON) {
        WaitingForRecieve = json["WaitingForRecieve"].intValue
        Success = json["Success"].stringValue
        AllOrderCounts = json["AllOrderCounts"].intValue
        Orders = json["Orders"].arrayValue.compactMap({ mOrders(json: $0)})
        WaitingForComments = json["WaitingForComments"].intValue
        WaitingForPay = json["WaitingForPay"].intValue
    }
}

struct mItemInfo {
    var version: String?
    var productId: Int = 0
    var VersionAlias: String?
    var ColorAlias: String?
    var SizeAlias: String?
    var count: Int = 0
    var SKuId: String?
    var RefundStats: String?
    var OrderRefundId: Int = 0
    var size: String?
    var productName: String?
    var image: String?
    var color: String?
    var EnabledRefundAmount: String?
    var Unit: String?
    var price: Int = 0
    
    init(json: JSON) {
        version = json["version"].stringValue
        productId = json["productId"].intValue
        VersionAlias = json["VersionAlias"].stringValue
        ColorAlias = json["ColorAlias"].stringValue
        SizeAlias = json["SizeAlias"].stringValue
        count = json["count"].intValue
        SKuId = json["SKuId"].stringValue
        RefundStats = json["RefundStats"].stringValue
        OrderRefundId = json["OrderRefundId"].intValue
        size = json["size"].stringValue
        productName = json["productName"].stringValue
        image = json["image"].stringValue
        color = json["color"].stringValue
        EnabledRefundAmount = json["EnabledRefundAmount"].stringValue
        Unit = json["Unit"].stringValue
        price = json["price"].intValue
    }
}

struct mOrders {
    var PaymentTypeValue: Int = 0
    var pickupCode: String?
    var orderStatus: Int = 0
    var HasAppendComment: Bool = false
    var id: Int = 0
    var InvoiceValue: Int = 0
    var InvoiceTitle: String?
    var status: String?
    var shopname: String?
    var vshopId: Int = 0
    var Invoice: String?
    var InvoiceContext: String?
    var orderTotalAmount: String?
    var EnabledRefundAmount: Int = 0
    var orderType: String?
    var PaymentType: String?
    var itemInfo = [mItemInfo]()
    var BisId: String?
    var CanRefund: Bool = false
    var productCount: Int = 0
    var OrderRefundId: Int = 0
    var orderTypeName: String?
    var RefundStats: Int = 0
    var HasExpressStatus: Bool = false
    var commentCount: Int = 0
    var ActualMoney: String?
    
    init(json: JSON) {
        PaymentTypeValue = json["PaymentTypeValue"].intValue
        pickupCode = json["pickupCode"].stringValue
        orderStatus = json["orderStatus"].intValue
        HasAppendComment = json["HasAppendComment"].boolValue
        id = json["id"].intValue
        InvoiceValue = json["InvoiceValue"].intValue
        InvoiceTitle = json["InvoiceTitle"].stringValue
        status = json["status"].stringValue
        shopname = json["shopname"].stringValue
        vshopId = json["vshopId"].intValue
        Invoice = json["Invoice"].stringValue
        InvoiceContext = json["InvoiceContext"].stringValue
        orderTotalAmount = json["orderTotalAmount"].stringValue
        EnabledRefundAmount = json["EnabledRefundAmount"].intValue
        orderType = json["orderType"].stringValue
        PaymentType = json["PaymentType"].stringValue
        itemInfo = json["itemInfo"].arrayValue.compactMap({ mItemInfo(json: $0)})
        BisId = json["BisId"].stringValue
        CanRefund = json["CanRefund"].boolValue
        productCount = json["productCount"].intValue
        OrderRefundId = json["OrderRefundId"].intValue
        orderTypeName = json["orderTypeName"].stringValue
        RefundStats = json["RefundStats"].intValue
        HasExpressStatus = json["HasExpressStatus"].boolValue
        commentCount = json["commentCount"].intValue
        ActualMoney = json["ActualMoney"].stringValue
    }
}

